# Import packages
library(dplyr)
library(data.table)
library(ggplot2)
# Setting environment
# remove(list=ls())
# setwd("C:\\Users\\sunil\\Downloads\\College\\DAV\\Project")
# make evironment not to change large number to exponential
options(scipen = 999)
# Import dataset
nepal_dt <- read.csv("Source Dataset-API_NPL_DS2.csv", skip=4, header=TRUE, stringsAsFactors = FALSE)
meta_country <- read.csv("MetaData_Country.csv", header=TRUE, stringsAsFactors = FALSE)
meta_indictr <- read.csv("MetaData_Indicator.csv", header=TRUE, stringsAsFactors = FALSE)
nepal_dt
meta_country
meta_indictr
temp_df = filter(nepal_dt, grepl("tax", tolower(IndicatorName), fixed = TRUE) | grepl("tax", tolower(IndicatorCode), fixed = TRUE))
nepal_df <- temp_df
nepal_df
dim(nepal_df)
[1] 53 66
temp_df = filter(nepal_dt, grepl("gdp", tolower(IndicatorName), fixed = TRUE) | grepl("gdp", tolower(IndicatorCode), fixed = TRUE))
nepal_df <- rbind(nepal_df, temp_df)
nepal_df
dim(nepal_df)
[1] 233 66
temp_df = filter(nepal_dt, grepl("employment", tolower(IndicatorName), fixed = TRUE) | grepl("employment", tolower(IndicatorCode), fixed = TRUE))
nepal_df <- rbind(nepal_df, temp_df)
nepal_df
# Drop first and second column
nepal_df <- nepal_df[-c(1,2)]
nepal_df
# unique(nepal_df$IndicatorName)
table(tolower(nepal_df$IndicatorName))
adequacy of unemployment benefits and almp (% of total welfare of beneficiary households)
1
agriculture, forestry, and fishing, value added (% of gdp)
1
benefit incidence of unemployment benefits and almp to poorest quintile (% of total u/almp benefits)
1
binding coverage, all products (%)
1
binding coverage, manufactured products (%)
1
binding coverage, primary products (%)
1
bound rate, simple mean, all products (%)
1
bound rate, simple mean, manufactured products (%)
1
bound rate, simple mean, primary products (%)
1
broad money (% of gdp)
1
central government debt, total (% of gdp)
1
child employment in agriculture (% of economically active children ages 7-14)
1
child employment in agriculture, female (% of female economically active children ages 7-14)
1
child employment in agriculture, male (% of male economically active children ages 7-14)
1
child employment in manufacturing (% of economically active children ages 7-14)
1
child employment in manufacturing, female (% of female economically active children ages 7-14)
1
child employment in manufacturing, male (% of male economically active children ages 7-14)
1
child employment in services (% of economically active children ages 7-14)
1
child employment in services, female (% of female economically active children ages 7-14)
1
child employment in services, male (% of male economically active children ages 7-14)
1
children in employment, female (% of female children ages 7-14)
1
children in employment, male (% of male children ages 7-14)
1
children in employment, self-employed (% of children in employment, ages 7-14)
1
children in employment, self-employed, female (% of female children in employment, ages 7-14)
1
children in employment, self-employed, male (% of male children in employment, ages 7-14)
1
children in employment, study and work (% of children in employment, ages 7-14)
1
children in employment, study and work, female (% of female children in employment, ages 7-14)
1
children in employment, study and work, male (% of male children in employment, ages 7-14)
1
children in employment, total (% of children ages 7-14)
1
children in employment, unpaid family workers (% of children in employment, ages 7-14)
1
children in employment, unpaid family workers, female (% of female children in employment, ages 7-14)
1
children in employment, unpaid family workers, male (% of male children in employment, ages 7-14)
1
children in employment, wage workers (% of children in employment, ages 7-14)
1
children in employment, wage workers, female (% of female children in employment, ages 7-14)
1
children in employment, wage workers, male (% of male children in employment, ages 7-14)
1
children in employment, work only (% of children in employment, ages 7-14)
1
children in employment, work only, female (% of female children in employment, ages 7-14)
1
children in employment, work only, male (% of male children in employment, ages 7-14)
1
claims on central government, etc. (% gdp)
1
claims on other sectors of the domestic economy (% of gdp)
1
co2 emissions (kg per 2015 us$ of gdp)
1
co2 emissions (kg per 2017 ppp $ of gdp)
1
co2 emissions (kg per ppp $ of gdp)
1
coal rents (% of gdp)
1
contributing family workers, female (% of female employment) (modeled ilo estimate)
1
contributing family workers, male (% of male employment) (modeled ilo estimate)
1
contributing family workers, total (% of total employment) (modeled ilo estimate)
1
coverage of unemployment benefits and almp (% of population)
1
coverage of unemployment benefits and almp in 2nd quintile (% of population)
1
coverage of unemployment benefits and almp in 3rd quintile (% of population)
1
coverage of unemployment benefits and almp in 4th quintile (% of population)
1
coverage of unemployment benefits and almp in poorest quintile (% of population)
1
coverage of unemployment benefits and almp in richest quintile (% of population)
1
current account balance (% of gdp)
1
current health expenditure (% of gdp)
1
customs and other import duties (% of tax revenue)
1
customs and other import duties (current lcu)
1
discrepancy in expenditure estimate of gdp (constant lcu)
1
discrepancy in expenditure estimate of gdp (current lcu)
1
domestic credit provided by financial sector (% of gdp)
1
domestic credit to private sector (% of gdp)
1
domestic credit to private sector by banks (% of gdp)
1
domestic general government health expenditure (% of gdp)
1
employers, female (% of female employment) (modeled ilo estimate)
1
employers, male (% of male employment) (modeled ilo estimate)
1
employers, total (% of total employment) (modeled ilo estimate)
1
employment in agriculture (% of total employment) (modeled ilo estimate)
1
employment in agriculture, female (% of female employment) (modeled ilo estimate)
1
employment in agriculture, male (% of male employment) (modeled ilo estimate)
1
employment in industry (% of total employment) (modeled ilo estimate)
1
employment in industry, female (% of female employment) (modeled ilo estimate)
1
employment in industry, male (% of male employment) (modeled ilo estimate)
1
employment in services (% of total employment) (modeled ilo estimate)
1
employment in services, female (% of female employment) (modeled ilo estimate)
1
employment in services, male (% of male employment) (modeled ilo estimate)
1
employment to population ratio, 15+, female (%) (modeled ilo estimate)
1
employment to population ratio, 15+, female (%) (national estimate)
1
employment to population ratio, 15+, male (%) (modeled ilo estimate)
1
employment to population ratio, 15+, male (%) (national estimate)
1
employment to population ratio, 15+, total (%) (modeled ilo estimate)
1
employment to population ratio, 15+, total (%) (national estimate)
1
employment to population ratio, ages 15-24, female (%) (modeled ilo estimate)
1
employment to population ratio, ages 15-24, female (%) (national estimate)
1
employment to population ratio, ages 15-24, male (%) (modeled ilo estimate)
1
employment to population ratio, ages 15-24, male (%) (national estimate)
1
employment to population ratio, ages 15-24, total (%) (modeled ilo estimate)
1
employment to population ratio, ages 15-24, total (%) (national estimate)
1
energy intensity level of primary energy (mj/$2017 ppp gdp)
1
energy use (kg of oil equivalent) per $1,000 gdp (constant 2017 ppp)
1
expense (% of gdp)
1
exports of goods and services (% of gdp)
1
external balance on goods and services (% of gdp)
1
female share of employment in senior and middle management (%)
1
final consumption expenditure (% of gdp)
1
firms expected to give gifts in meetings with tax officials (% of firms)
1
firms that do not report all sales for tax purposes (% of firms)
1
firms visited or required meetings with tax officials (% of firms)
1
foreign direct investment, net inflows (% of gdp)
1
foreign direct investment, net outflows (% of gdp)
1
forest rents (% of gdp)
1
gdp (constant 2015 us$)
1
gdp (constant lcu)
1
gdp (current lcu)
1
gdp (current us$)
1
gdp deflator (base year varies by country)
1
gdp deflator: linked series (base year varies by country)
1
gdp growth (annual %)
1
gdp per capita (constant 2015 us$)
1
gdp per capita (constant lcu)
1
gdp per capita (current lcu)
1
gdp per capita (current us$)
1
gdp per capita growth (annual %)
1
gdp per capita, ppp (constant 2017 international $)
1
gdp per capita, ppp (current international $)
1
gdp per person employed (constant 2017 ppp $)
1
gdp per unit of energy use (constant 2017 ppp $ per kg of oil equivalent)
1
gdp per unit of energy use (ppp $ per kg of oil equivalent)
1
gdp, ppp (constant 2017 international $)
1
gdp, ppp (current international $)
1
gdp: linked series (current lcu)
1
general government final consumption expenditure (% of gdp)
1
government expenditure on education, total (% of gdp)
1
government expenditure per student, primary (% of gdp per capita)
1
government expenditure per student, secondary (% of gdp per capita)
1
government expenditure per student, tertiary (% of gdp per capita)
1
gross capital formation (% of gdp)
1
gross domestic savings (% of gdp)
1
gross fixed capital formation (% of gdp)
1
gross fixed capital formation, private sector (% of gdp)
1
gross national expenditure (% of gdp)
1
gross savings (% of gdp)
1
gross value added at basic prices (gva) (constant 2015 us$)
1
gross value added at basic prices (gva) (constant lcu)
1
gross value added at basic prices (gva) (current lcu)
1
gross value added at basic prices (gva) (current us$)
1
households and npishs final consumption expenditure (% of gdp)
1
imports of goods and services (% of gdp)
1
industry (including construction), value added (% of gdp)
1
inflation, gdp deflator (annual %)
1
inflation, gdp deflator: linked series (annual %)
1
labor tax and contributions (% of commercial profits)
1
manufacturing, value added (% of gdp)
1
market capitalization of listed domestic companies (% of gdp)
1
merchandise trade (% of gdp)
1
military expenditure (% of gdp)
1
mineral rents (% of gdp)
1
monetary sector credit to private sector (% gdp)
1
natural gas rents (% of gdp)
1
net acquisition of financial assets (% of gdp)
1
net incurrence of liabilities, total (% of gdp)
1
net investment in nonfinancial assets (% of gdp)
1
net lending (+) / net borrowing (-) (% of gdp)
1
number of visits or required meetings with tax officials (average for affected firms)
1
oil rents (% of gdp)
1
other taxes (% of revenue)
1
other taxes (current lcu)
1
other taxes payable by businesses (% of commercial profits)
1
part time employment, female (% of total female employment)
1
part time employment, male (% of total male employment)
1
part time employment, total (% of total employment)
1
personal remittances, received (% of gdp)
1
ppp conversion factor, gdp (lcu per international $)
1
price level ratio of ppp conversion factor (gdp) to market exchange rate
1
profit tax (% of commercial profits)
1
research and development expenditure (% of gdp)
1
revenue, excluding grants (% of gdp)
1
self-employed, female (% of female employment) (modeled ilo estimate)
1
self-employed, male (% of male employment) (modeled ilo estimate)
1
self-employed, total (% of total employment) (modeled ilo estimate)
1
services, value added (% of gdp)
1
share of tariff lines with international peaks, all products (%)
1
share of tariff lines with international peaks, manufactured products (%)
1
share of tariff lines with international peaks, primary products (%)
1
share of tariff lines with specific rates, all products (%)
1
share of tariff lines with specific rates, manufactured products (%)
1
share of tariff lines with specific rates, primary products (%)
1
share of youth not in education, employment or training, female (% of female youth population)
1
share of youth not in education, employment or training, male (% of male youth population)
1
share of youth not in education, employment or training, total (% of youth population)
1
stocks traded, total value (% of gdp)
1
tariff rate, applied, simple mean, all products (%)
1
tariff rate, applied, simple mean, manufactured products (%)
1
tariff rate, applied, simple mean, primary products (%)
1
tariff rate, applied, weighted mean, all products (%)
1
tariff rate, applied, weighted mean, manufactured products (%)
1
tariff rate, applied, weighted mean, primary products (%)
1
tariff rate, most favored nation, simple mean, all products (%)
1
tariff rate, most favored nation, simple mean, manufactured products (%)
1
tariff rate, most favored nation, simple mean, primary products (%)
1
tariff rate, most favored nation, weighted mean, all products (%)
1
tariff rate, most favored nation, weighted mean, manufactured products (%)
1
tariff rate, most favored nation, weighted mean, primary products (%)
1
tax payments (number)
1
tax revenue (% of gdp)
2
tax revenue (current lcu)
1
taxes less subsidies on products (constant lcu)
1
taxes less subsidies on products (current lcu)
1
taxes less subsidies on products (current us$)
1
taxes on exports (% of tax revenue)
1
taxes on exports (current lcu)
1
taxes on goods and services (% of revenue)
1
taxes on goods and services (% value added of industry and services)
1
taxes on goods and services (current lcu)
1
taxes on income, profits and capital gains (% of revenue)
1
taxes on income, profits and capital gains (% of total taxes)
1
taxes on income, profits and capital gains (current lcu)
1
taxes on international trade (% of revenue)
1
taxes on international trade (current lcu)
1
time to prepare and pay taxes (hours)
1
total natural resources rents (% of gdp)
1
total tax and contribution rate (% of profit)
1
trade (% of gdp)
1
trade in services (% of gdp)
1
unemployment with advanced education (% of total labor force with advanced education)
1
unemployment with advanced education, female (% of female labor force with advanced education)
1
unemployment with advanced education, male (% of male labor force with advanced education)
1
unemployment with basic education (% of total labor force with basic education)
1
unemployment with basic education, female (% of female labor force with basic education)
1
unemployment with basic education, male (% of male labor force with basic education)
1
unemployment with intermediate education (% of total labor force with intermediate education)
1
unemployment with intermediate education, female (% of female labor force with intermediate education)
1
unemployment with intermediate education, male (% of male labor force with intermediate education)
1
unemployment, female (% of female labor force) (modeled ilo estimate)
1
unemployment, female (% of female labor force) (national estimate)
1
unemployment, male (% of male labor force) (modeled ilo estimate)
1
unemployment, male (% of male labor force) (national estimate)
1
unemployment, total (% of total labor force) (modeled ilo estimate)
1
unemployment, total (% of total labor force) (national estimate)
1
unemployment, youth female (% of female labor force ages 15-24) (modeled ilo estimate)
1
unemployment, youth female (% of female labor force ages 15-24) (national estimate)
1
unemployment, youth male (% of male labor force ages 15-24) (modeled ilo estimate)
1
unemployment, youth male (% of male labor force ages 15-24) (national estimate)
1
unemployment, youth total (% of total labor force ages 15-24) (modeled ilo estimate)
1
unemployment, youth total (% of total labor force ages 15-24) (national estimate)
1
vulnerable employment, female (% of female employment) (modeled ilo estimate)
1
vulnerable employment, male (% of male employment) (modeled ilo estimate)
1
vulnerable employment, total (% of total employment) (modeled ilo estimate)
1
wage and salaried workers, female (% of female employment) (modeled ilo estimate)
1
wage and salaried workers, male (% of male employment) (modeled ilo estimate)
1
wage and salaried workers, total (% of total employment) (modeled ilo estimate)
1
water productivity, total (constant 2015 us$ gdp per cubic meter of total freshwater withdrawal)
1
# t(nepal_df)
df_t <- transpose(nepal_df)
rownames(df_t) <- colnames(nepal_df)
colnames(df_t) <- rownames(nepal_df)
# Rename the columns with the first row. Columns are not properly renamed from above lines.
colnames(df_t) <- df_t[1,]
# Remove the first row.
df_t <- df_t[-1:-2,]
nepal_df <- df_t
nepal_df
nepal_df[0]
df_t <- nepal_df %>% mutate_if(is.character, as.numeric)
[1m[33mError[39m in `pull()`:[22m
[33m![39m Problem while evaluating `tibble_vars[[.env$i]]`.
[1mCaused by error:[22m
[1m[22m[33m![39m `data` must be uniquely named but has duplicate columns
[90mRun `rlang::last_error()` to see where the error occurred.[39m
'length(x) = 10 > 1' in coercion to 'logical(1)''length(x) = 10 > 1' in coercion to 'logical(1)'
cor(nepal_df)
Error in cor(nepal_df) : 'x' must be numeric
plot(nepal_df)
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.